//
//  JMBCouponDoingCell.m
//  SYPerfectDemo
//
//  Created by Lssyyy on 2019/8/7.
//  Copyright © 2019年 Lssyyy. All rights reserved.
//

#import "JMBCouponDoingCell.h"
#import "JMCouponCellNumberView.h"
#import "UIButton+SYImageLocation.h"
@interface JMBCouponDoingCell()
@property (nonatomic,strong) UIView *backView;
@property (nonatomic,strong) UIImageView *couponIconImageView;
@property (nonatomic,strong) UILabel *conditionLabel;
@property (nonatomic,strong) UILabel *timeLabel;
@property (nonatomic,strong) UISwitch *switchButton;
@property (nonatomic,strong) UIButton *deleteButton;
@property (nonatomic,strong) JMCouponCellNumberView *numberView;
@end

@implementation JMBCouponDoingCell

- (void)addUI{
    [super addUI];
    self.contentView.backgroundColor = UIColorHex(F6F6F6);
    _backView = [UIView new];
    _backView.backgroundColor = [UIColor whiteColor];
    _backView.layer.cornerRadius = 8.0;
    _backView.layer.masksToBounds = YES;
    [self.contentView addSubview:_backView];
    
    _couponIconImageView = [UIImageView new];
    _couponIconImageView.image = [UIImage imageNamed:@"icon_coupon"];
    [_backView addSubview:_couponIconImageView];
    
    _conditionLabel = [UILabel new];
    _conditionLabel.text = @"满200-100";
    _conditionLabel.textColor = UIColorHex(282828);
    _conditionLabel.font = [UIFont systemFontOfSize:15];
    [_backView addSubview:_conditionLabel];
    
    _timeLabel = [UILabel new];
    _timeLabel.text = @"2019-10-01至2019-10-07";
    _timeLabel.textColor = UIColorHex(B2B2B2);
    _timeLabel.font = [UIFont systemFontOfSize:12];
    [_backView addSubview:_timeLabel];
    
    _switchButton = [UISwitch new];
    _switchButton.on = YES;
    [_backView addSubview:_switchButton];
    
    _deleteButton = [UIButton buttonWithType:0];
    [_deleteButton setTitleColor:UIColorHex(282828) forState:UIControlStateNormal];
    [_deleteButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [_deleteButton setTitle:JMLocalStr(@"删除") forState:UIControlStateNormal];
    [_deleteButton setImage:[UIImage imageNamed:@"icon_couponDelete"] forState:UIControlStateNormal];
    [_backView addSubview:_deleteButton];
    
    _numberView = [JMCouponCellNumberView viewFromXib];
    [_backView addSubview:_numberView];
    
    
    _backView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10);
    
    _switchButton.sd_layout
    .rightSpaceToView(_backView, 15)
    .topSpaceToView(_backView, 15)
    .heightIs(26)
    .widthIs(50);
    
    _couponIconImageView.sd_layout
    .leftSpaceToView(_backView, 15)
    .topSpaceToView(_backView, 15)
    .widthIs(17)
    .heightIs(14);
    
    _conditionLabel.sd_layout
    .leftSpaceToView(_couponIconImageView, 5)
    .centerYEqualToView(_couponIconImageView)
    .heightIs(18)
    .rightSpaceToView(_switchButton, 10);
    
    _timeLabel.sd_layout
    .leftSpaceToView(_backView, 15)
    .topSpaceToView(_couponIconImageView, 8)
    .heightIs(15)
    .rightSpaceToView(_switchButton, 10);
    
    _numberView.sd_layout
    .leftEqualToView(_backView)
    .rightEqualToView(_backView)
    .topSpaceToView(_timeLabel, 15)
    .heightIs(80);
    
    _deleteButton.sd_layout
    .leftEqualToView(_backView)
    .rightEqualToView(_backView)
    .topSpaceToView(_numberView,0)
    .heightIs(48);
    
    [_backView setupAutoHeightWithBottomView:_deleteButton bottomMargin:0];
    [self.contentView setupAutoHeightWithBottomView:_backView bottomMargin:0];
    
    [_deleteButton setImageEdgeInsets:UIEdgeInsetsMake(0.0, -10, 0.0, 0.0)];
}

@end
